<?php
/**
 * Created by PhpStorm.
 * User: Dave
 * Date: 2018/4/24
 * Time: 15:46
 */

namespace Biz\module\Classes\adm;

use Biz\model\trade\OrderPay as mOrderPay;
use Biz\pockets\excel\DownExcel;


class FlashSaleExcel
{
    /**
     * 数据下载
     * @throws \Exception
     */
    public static function downList()
    {
//        $header = ['商品ID', 'skuId', '开始时间', '结束时间', 'sku价格', '活动价', '活动库存', '卖点', '限购数量'];
        $header = ['商品ID', 'skuId', '开始时间', '结束时间', '活动价', '活动库存', '卖点', '限购数量'];

        $downList[] = [
            'goods_id' => 616880 ,
            'sku_id' => 2228709,
            'start_time' => '开始时间的格式为 : 2018-11-30 00:00:00',
            'end_time' => '结束时间的格式为 : 2018-12-01 00:00:00',
//            'sku_price' => '119',
            'activity_price' => '8',
            'stock' => 1,
            'describe' => '模板参考数据，记得删除~',
            'limit_but_count' => '1',
        ];
        $letter = range('A', 'I');

        $excelObj = new DownExcel();
        $excelObj->setFileName('限时购模板');
        $excelObj->setSheetTitle('限时购模板');
        //设置列宽
//        $widths = ['A' => 20, 'B' => 30, 'C' => 40, 'D' => 40, 'E' => 15, 'F' => 15, 'G' => 15, 'H' => 50, 'I' => 10];
        $widths = ['A' => 20, 'B' => 30, 'C' => 40, 'D' => 40, 'E' => 15, 'F' => 15, 'G' => 50, 'H' => 10];
        $excelObj->setWidth($widths);
        //默认单元格居中
        $excelObj->setDefaultStyleAlignment();
        foreach ($header as $key => $value) {
            //设置字体
            $excelObj->setFrontName($letter[$key]);
            //设置大小
            $excelObj->setFrontSize($letter[$key]);
        }

        $excelObj->create($downList, $header);
        return true;
    }

}